package logic

import (
	"context"
	"house_srv/models"

	"house_srv/house"
	"house_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type RentListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRentListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RentListLogic {
	return &RentListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 我的预约展示
func (l *RentListLogic) RentList(in *house.RentListRequest) (*house.RentListResponse, error) {
	// todo: add your logic here and delete this line
	var rents []models.Rent
	models.DB.Debug().Find(&rents)
	var rentLists []*house.RentList
	for _, rent := range rents {
		list := house.RentList{
			UserId:  rent.UserId,
			HouseId: int64(rent.HouseId),
			MindMan: rent.MidMan,
			Tel:     rent.Tel,
		}
		rentLists = append(rentLists, &list)
	}
	return &house.RentListResponse{
		List: rentLists,
	}, nil
}
